package com.healthtop.web;

import com.healthtop.common.Page;
import com.healthtop.common.Specification;
import com.healthtop.common.Views;
import com.healthtop.dto.XsGameGategoryDto;
import com.healthtop.service.DIYService;
import com.healthtop.service.XsGameGategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/xsGameGategory")
public class XsGameGategoryController {

    @Autowired
    private XsGameGategoryService xsGameGategoryService;

    @Autowired
    private DIYService diyService;

    /**
     * 获取列表
     * @param page
     * @return
     */
    @RequestMapping("/list")
    public String list(Page page){
       diyService.selectXsGameGategoryPage(page);
       return Views.XS_GAME_GATEGORY_LIST;
    }


    /**
     * 进入新增/编辑页面
     * @param xsGameGategoryDto
     * @return
     */
    @RequestMapping("/forward")
    public String forward(XsGameGategoryDto xsGameGategoryDto){
        if(xsGameGategoryDto.getMode()== Specification.OperateMode.UPDATE.index||xsGameGategoryDto.getMode()==Specification.OperateMode.VIEW.index){
            xsGameGategoryService.selectById(xsGameGategoryDto);
        }
        return Views.XS_GAME_GATEGORY_FORM;
    }

    /**
     * 进行新增/编辑操作
     * @param xsGameGategoryDto
     * @return
     */
    @RequestMapping("/operate")
    public String operate(XsGameGategoryDto xsGameGategoryDto){
        xsGameGategoryService.operate(xsGameGategoryDto);
        return Views.REDIRECT_XS_GAME_GATEGORY_List;
    }

    /**
     * 进行删除操作
     * @param xsGameGategoryDto
     * @return
     */
    @RequestMapping("/delete")
    public String delete(XsGameGategoryDto xsGameGategoryDto){
        xsGameGategoryService.delete(xsGameGategoryDto);
        return Views.REDIRECT_XS_GAME_GATEGORY_List;
    }
}
